<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<script type="text/javascript" src="../../res/js/jquery-3.1.1.min.js"></script>
<link rel="stylesheet" href="../../res/layui/css/layui.css" media="all">
<script src="../../res/layui/layui.js"></script>
<script src="../../res/js/Tools.js"></script>
<body>
<form class="layui-form" action="" lay-filter="example" id="example">
    <input type="hidden" name="auId" id="auId">
    <input type="hidden" name="saId" id="saId">
    <input type="hidden" name="athleteId" id="athleteId">

    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label">审核意见</label>
        <div class="layui-input-block">
            <textarea placeholder="请输入内容" class="layui-textarea"  name="auExp" id="auExp" lay-verify="required"></textarea>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">选择专家</label>
        <div class="layui-input-block">
            <select name="expertId" id="expertName"  lay-verify="required">
            </select>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button type="submit" class="layui-btn" lay-submit="" lay-filter="demo">确认同意</button>
        </div>
    </div>
</form>
</body>
<script>
    $(function(){
        select();
    });
    function select(){
        $.ajax({
            url:"../../atsAduit/selectAll",
            type:"post",
            async:false, // 全局同步
            dataType:"json",
            data:{},
            success:function(data){
                if(data !=null && data !=""){
                    layui.use(['layer','form'],function(){
                        var form = layui.form;
                        var html = '<option value="" >选择专家</option>';
                        for(var i=0;i<data.length;i++){;
                            html +='<option value="' +  data[i].expertId + '" id="'+data[i].expertId+'">' +   data[i].expertName + '</option>';
                        }
                        $("#expertName").html(html);
                        form.render();
                    });

                }
            }
        });
    };
    layui.use('form',function(){
        var form = layui.form;
        var saId = getQueryString("saId");
        $("#saId").val(saId);

        form.on('submit(demo)',function(){
            var url="../../atsAduit/update";
            var formdata = new FormData(document.getElementById("example"));

            $.ajax({
                url:url,
                type:"post",
                data:formdata,
                async:false, // 全局同步
                processData:false,
                contentType:false,
                dataType:"json",
                success:function(obj){

                    if(obj.num==1){

                        layer.msg('操作成功',{
                            icon:1,
                            time:1000,
                        },function(){
                            var indexs = parent.layer.getFrameIndex(window.name);
                            parent.layer.close(indexs);
                        });

                    }else{
                        layer.msg("操作失败");
                    }
                },
                error:function(e){
                    alert("失败");
                }
            });
            return false;
        })
    });
</script>
</html>